package LeetCode.leetcode404;

public class Review1 {
    public int sumOfLeftLeaves(TreeNode root) {
        return getRes(root,0);
    }

    public static int getRes(TreeNode node, int sum) {
        if (node.left != null && node.left.left == null && node.left.right == null) {
            return sum += node.left.val;
        }
        if (node.left != null && node.right == null){
            return getRes(node.left,sum);
        }else if (node.left == null && node.right != null){
            return getRes(node.right,sum);
        }else if (node.left != null && node.right != null){
            return getRes(node.left,sum) + getRes(node.right,sum);
        }
        return sum;
    }
}
